package com.qst.rongxiaotong.service.serviceImpl;

import com.qst.rongxiaotong.context.BaseContext;
import com.qst.rongxiaotong.mapper.ReserveMapper;
import com.qst.rongxiaotong.pojo.Reserve;
import com.qst.rongxiaotong.service.ReserveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReserveServiceImpl implements ReserveService {
    @Autowired
    ReserveMapper reserveMapper;

    @Override
    public List<Reserve> selectByKind(String kind) {
        String username = BaseContext.getCurrentuserName();
        Reserve reserve = new Reserve();
        if("questioner".equals(kind)){
            reserve.setQuestioner(username);
        }else{
            reserve.setExpertName(username);
        }
        List<Reserve> reserves=reserveMapper.selectByKind(reserve);
        return reserves;
    }

    @Override
    public Reserve selectById(Integer id) {
        Reserve reserve = reserveMapper.selectById(id);
        return reserve;
    }

    @Override
    public int deleteById(Integer id) {
        int row = reserveMapper.deleteById(id);
        return row;
    }

    @Override
    public void updateById(Reserve reserve) {
        reserveMapper.updateById(reserve);
    }

    @Override
    public void addReserve(Reserve reserve) {
        reserveMapper.addReserve(reserve);
    }
    public void insert(Reserve reserve) {
        reserveMapper.insertSelective(reserve);
    }
}
